package com.bwie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bwie.pojo.TbBrand;
import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/brand/prod")
public class ProdController {

    @Autowired
    TbProdService prodService;

    @PostMapping("/brandPageInfo")
    public R brandPageInfo(@RequestBody PageInfoVo pageInfoVo){

        return prodService.pageIngefo(pageInfoVo);
    }

    @ApiOperation("标签列表")
    @PostMapping("/getTagList")
    public R getTagList(){
        return prodService.getTagList();
    }

    @ApiOperation("字典表列表")
    @PostMapping("/getDictList")
    public R getDictList(){
        return prodService.getDictList();
    }

    @ApiOperation("单位列表")
    @PostMapping("/getUnitList")
    public R getUnitList(){
        return prodService.getUnitList();
    }

    @ApiOperation("供应商列表")
    @PostMapping("/apprList")
    public R apprList(){
        return prodService.apprList();
    }

    @ApiOperation("图上传")
    @PostMapping("/uploadImage")
    public R uploadImage(@RequestPart(name = "file")MultipartFile file){

        return prodService.uploadImage(file);
    }

    @ApiOperation("品牌列表")
    @PostMapping("/getBrandList")
    public R getBrandList(){
        return prodService.getBrandList();
    }

    @ApiOperation("获取分类型tree")
    @PostMapping("/getTypeMenuList")
    public R getTypeMenuList(){

        return prodService.getTypeMenuList();
    }

    @ApiOperation("商品添加")
    @PostMapping("/prodSave")
    public R prodSave(@RequestBody TbProd tbProd){

        return prodService.prodSave(tbProd);
    }

    @ApiOperation("批量删除")
    @PostMapping("/deleteAll")
    public R deleteAll(@RequestBody List<TbProd>prodList){

        return prodService.deleteAll(prodList);
    }

}
